<% layout('/layouts/default.html', {title: '任务部署信息表(主)管理', libs: ['validate','fileupload','dataGrid']}){ %>
<div class="main-content">
    <div class="box box-main">
        <#form:form id="inputForm" model="${editAllInfo}" action="${ctx}/taskdeploy/dcSupTaskInfo/saveEditAllInfo"
        method="post" class="form-horizontal">
        <div class="box-body">
            <div class="form-unit">${text('可修改项')}</div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                        </label>
                        <div class="col-sm-8">
                            <#form:hidden path="id"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('任务年度')}：<i
                                class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:select path="taskYear" items="${yearList}" blankOption="true" data-placeholder="请选择"
                            itemLabel="yearLabel" itemValue="yearValue" class="form-control width-120 required" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('任务类型')}：<i
                                class="fa icon-question hide"></i></label>
                        <div class="col-sm-8" style="padding-right: 50px;position: relative">
                            <#form:select path="taskTypeCode" items="${dicts}" blankOption="true"
                            data-placeholder="请选择任务类型" itemLabel="dictLabel" itemValue="dictValue" class="form-control width-120 required" />
                            <#form:hidden path="taskTypeName"/>
                        </div>
                    </div>
                </div>
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="control-label col-sm-2" title="">
                            <span class="required ">*</span> ${text('任务标题')}：<i
                                class="fa icon-question hide"></i></label>
                        <div class="col-sm-10">
                            <#form:textarea path="taskTitle" rows="2" class="form-control required" autocomplete="off"
                            placeholder="任务标题，限制200字以内" maxlength="200"/>
                        </div>
                    </div>
                </div>
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="control-label col-sm-2" title="">
                            <span class="required ">*</span> ${text('任务内容')}：<i
                                class="fa icon-question hide"></i></label>
                        <div class="col-sm-10">
                            <#form:textarea path="taskContent" rows="5" placeholder="任务内容，限制1000字以内" class="form-control required" style="white-space: pre-line;" maxlength="1000"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="control-label col-sm-2" title="">
                            <span class="required hide">*</span> ${text('督办要求')}：<i
                                class="fa icon-question hide"></i></label>
                        <div class="col-sm-10">
                            <#form:textarea path="taskRequireName" rows="3" class="form-control" autocomplete="off"
                            maxlength="1000" placeholder="督办要求，限制1000字以内" />
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required hide">*</span> ${text('排序编号')}：<i
                                class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="sortNum" maxlength="10" min="1" class="form-control digits"
                            placeholder="排序编号" />
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('督办字号')}：<i
                                class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <div style="width: 60%;float:left;">
                                <#form:select path="msgNum" dictType="${msgType}" onchange ="changeOne()"
                                blankOption="false" class="form-control"/>
                                <#form:hidden id="msgType" value="${msgType}"/>
                            </div>
                            <div style="width: 40%;float:left;padding-left: 2px;">
                                <#form:input path="msgNum2" maxlength="100" value="${editAllInfo.messageNumber}"
                                placeholder="督办字号" maxlength="10" min="1" class="form-control digits required"/>
                                <#form:hidden path="messageNumber"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <% if(editAllInfo.normalFlag=='2'){ %>
        <div class="row">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="control-label col-sm-2">
                        <span class="required hide">*</span> ${text('督办科室')}：</label>
                    <div class="col-sm-4">
                        <#form:select path="taskSupOrg" dictType="dc_task_department"  blankOption="true" data-placeholder="请选择督办科室"  class="form-control width-120" />
                        <#form:hidden path="taskSupOrgName" />
                    </div>
                </div>
            </div>
        </div>
            <% } %>
        <div class="row">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="control-label col-sm-2">
                        <span class="required hide">*</span> ${text('附件上传')}：</label>
                    <div class="col-sm-10">
                        <#form:fileupload id="uploadFile" bizKey="${editAllInfo.id}" bizType="dcSupTaskInfo_file"
                        uploadType="all" class="" readonly="false" preview="true" maxUploadNum="10"/>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="box-footer">
        <div class="row">
            <div class="col-sm-offset-2 col-sm-10">
                <% if (hasPermi('taskdeploy:dcSupTaskInfo:edit')){ %>
                <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit" onclick="changeStatus();"><i
                        class="fa fa-check"></i> ${text('保存修改')}
                </button>&nbsp;
                <% } %>
                <button type="button" class="btn btn-sm btn-default btnList" id="btnCancel"
                        onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}
                </button>
            </div>
        </div>
    </div>
</#form:form>
</div>
</div>
<% } %>
<script>
    function changeStatus() {
        $("#messageNumber").val($("#msgNum").find("option:selected").text() + $("#msgNum2").val());
        $("#taskSupOrgName").val($("#taskSupOrg").find("option:selected").text());
        $("#inputForm").validate({
            submitHandler: function (form) {
                $("#taskTypeName").val($("#taskTypeCode").find("option:selected").text());
                js.ajaxSubmitForm($(form), function (data) {
                    js.showMessage(data.message);
                    if (data.result == Global.TRUE) {
                        js.closeCurrentTabPage(function (contentWindow) {
                            contentWindow.page();
                        });
                    }
                }, "json");
            }
        });
    }
    $("#msgNum2").val(`${editAllInfo.messageNumber}`)
</script>

<script>
    var msgNum2 = $('#msgNum2').val();
    if (msgNum2.length == 0) {
        changeOne();
    } else {
        $('#msgNum').val(msgNum2.substring(0, msgNum2.indexOf('〕') + 1));
        $('#msgNum2').val(msgNum2.substring(msgNum2.indexOf('〕') + 1));
    }

    function changeOne() {
        var msgNum = $('#msgNum').val();
        msgNum = msgNum.substring(0, msgNum.indexOf('〔'))
        $.ajax({
            type: 'get',
            url: "${ctx}/taskdeploy/dcSupTaskInfo/getMaxMessageNumberByType?msgNum=" + msgNum,
            success: function (res) {
                $('#msgNum2').val(Number(res.data.msgNum2) + 1);
            }
        })
    }
</script>